define(['backbone'], function(Backbone) {
    var items = [{
        'index':'A',
        'avatar':'http://img3.imgtn.bdimg.com/it/u=81535881,1922013000&fm=21&gp=0.jpg',
        'member_id': '201604100000001',
        'real_name': 'A北京阿里支付宝公司',
        'j_count': 50
    },{
        'index':'C',
        'avatar':'http://img3.imgtn.bdimg.com/it/u=52013333,953582506&fm=21&gp=0.jpg',
        'member_id': '201604100000013',
        'real_name': 'C北京阿里支付宝公司',
        'j_count': 30
    },{
        'index':'C',
        'avatar':'http://img3.imgtn.bdimg.com/it/u=52013333,953582506&fm=21&gp=0.jpg',
        'member_id': '201604100000013',
        'real_name': 'C北京阿里支付宝公司',
        'j_count': 30
    },{
        'index':'C',
        'avatar':'http://img3.imgtn.bdimg.com/it/u=52013333,953582506&fm=21&gp=0.jpg',
        'member_id': '201604100000013',
        'real_name': 'C北京阿里支付宝公司',
        'j_count': 30
    },{
        'index':'C',
        'avatar':'http://img3.imgtn.bdimg.com/it/u=52013333,953582506&fm=21&gp=0.jpg',
        'member_id': '201604100000013',
        'real_name': 'C北京阿里支付宝公司',
        'j_count': 30
    },{
        'index':'C',
        'avatar':'http://img3.imgtn.bdimg.com/it/u=52013333,953582506&fm=21&gp=0.jpg',
        'member_id': '201604100000013',
        'real_name': 'C北京阿里支付宝公司',
        'j_count': 30
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'D',
        'avatar':'http://img5.imgtn.bdimg.com/it/u=332323756,2994884593&fm=21&gp=0.jpg',
        'member_id': '201604100000014',
        'real_name': 'D北京阿里支付宝公司',
        'j_count': 20
    },{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    },{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    },{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    },{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    },,{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    },{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    },{
        'index':'E',
        'avatar':'http://img1.imgtn.bdimg.com/it/u=2340958506,872894113&fm=21&gp=0.jpg',
        'member_id': '201604100000015',
        'real_name': 'E北京阿里支付宝公司',
        'j_count': '10'
    }];

    var TaskModel = Backbone.Model.extend({
        defaults: function() {
            return {
                'title': '采购报销单'
            };
        },
        destroy:function(){
            this.trigger('destroy');
        }
    });


    var collections = Backbone.Collection.extend({
        model: TaskModel,
        url: "./api/showcase",
        state: {},
        initialize:function(){
            //this.reset(items);
        },
        fetch: function() {
            // this.addItem();
            //this.reset(items);
        },

        addItem: function(){
            for (var i = 0; i < this.pageSize; i++) {
                var position = this.curPageIndex * this.pageSize + i;
                if(items.length > position){
                    this.add(new TaskModel(items[position]));
                }else{
                    break;
                }
            }

        },

        curPageIndex: 0,
        pageSize: 10,
        getNextPage: function() {
            this.curPageIndex += 1;
            this.addItem();
        },
        hasNextPage: function() {
            return items.length/ this.pageSize > this.curPageIndex;
        },
        getFirstPage: function() {
            this.curPageIndex = 0;
            this.addItem();
        },
    });

    return collections;
});
